<extend name="Index/index"/>


<block name="main">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Home/css/BBSinvitAdd.css">
	
	<div id="BBSedit">
		<p class="ppp"></p>
		<form action="<{:U('BBSinvit/BBSinvitAdd')}>" method="post">
			<p class="ppp">请输入文章标题</p>
			<input id="intitle" type="text" name="intitle">
			<div id="BBSdiv">
				<select id="BBStype01">
				</select>
	   			<select id="BBStype02" name="pid">
	   			</select>
   			</div>


			<script id="container" name="intext" type="text/plain" style="width:858px;height:500px">

			</script>
		<p class="ppp"></p>	
		<input type="hidden" id="BBStypeID" name="uid" value="<{$_SESSION['uid']}>">
		<button  id="btn">发帖</button>
		</form>
		<script type="text/javascript" src="__PUBLIC__/Home/UEditor/ueditor.config.js"></script>
		<script type="text/javascript" src="__PUBLIC__/Home/UEditor/ueditor.all.js"></script>
		<script type="text/javascript">
			var ue = UE.getEditor('container');
		</script>
		<p class="ppp"></p>	
	</div>









</block>



<block name="left">
	
</block>

<block name="foot">
	<script>
		
		//获取一级分类数据
		$.ajax({
			type:'GET',
			url:"<{:U('BBSinvit/BBSinvitAjax')}>",
			async:false,
			success:function(data){
			
				$('#BBStype01').empty();
				//遍历一级分类数据
				for (var i =0; i < data.length; i++) {
					$('<option value="'+data[i].tid+'">'+data[i].tname+'</option>').appendTo('#BBStype01');
				}
			},
			dataType:'json',
		})

		//绑定事件
		$('#BBStype01,#BBStype02').change(function(){
			
			var fid = $(this).val();
			
			//清空之前的所有数据
			$(this).nextAll('select').empty();
			//保留$(this)的值
			var _this = $(this);
			//请求下一级的数据
			$.ajax({
				type:'GET',
				url:"<{:U('BBSinvit/BBSinvitAjax')}>",
				data:"fid="+fid,
				async:false,
				success:function(data){

					for (var i=0; i<data.length; i++){
						
						$('<option value="'+data[i].tid+'">'+data[i].tname+'</option>').appendTo(_this.next('select'));
					}
					
					//自动触发 后面的select的change事件
					_this.next('select').trigger('change');
				},
				dataType:'json',
			})
		})
		$('#BBStype01').trigger('change');
	</script>
</block>